import React, { useEffect, useRef, useState } from 'react'
import {
  Tabs,
  Input,
  List,
  Avatar,
  Row,
  Col,
  Space,
  AutoComplete,
  Divider,
  Select,
  Button,
  Form,
  message,
  Image
} from 'antd'
// import {
//   reqPatientList,
//   reqDetal,
//   reqUpdate,
//   reqPulseUpdate,
//   reqPulseDetail,
//   reqPulseList,
//   reqQuestionTermList
// } from '@/services/basicConsultation';

import {
  reqPulseCalibrationList,
  reqTongueCalibrationList,
  reqDiagnosisTermList,
  reqDiagnosisTermListByGrade,
  reqSeniorInquiryList,
  reqSeniorInquiryUpdate,
  reqSymptomList,
  reqSymptomListByGrade
} from '@/services/firstConsultation';

import CheckListButton from '@/components/CheckListButton'


import styles from './index.module.less'

const TongueCalibration = ({
  user,
  upDataInfo,
  readonly
}) => {
  const [options, setOptions] = useState<any>([])


  async function init() {
    try {
      const res = await reqTongueCalibrationList({
        pageNum: 1,
        pageSize: 10,
      })

      console.log('获取舌诊标定列表信息 :>> ', res?.data);
      if (res?.resultCode == '00000000') {
        let newOptions = []
        res?.data?.result?.map((item) => {
          newOptions.push({
            label: item?.name,
            value: item?.name
          })
        })

        setOptions(newOptions)
        // setData
      } else {
        message.error(`获取舌诊标定列表信息出错！${res?.message}`)
      }
    } catch (error: any) {
      message.error('获取舌诊标定列表信息出错！', error)
      console.log('获取舌诊标定列表信息出错！ :>> ', error);
    }
  }


  useEffect(() => {
    init()
  }, [])

  function onChange(params: any) {
    upDataInfo && upDataInfo({
      ...user.seniorInquiry,
      tyTongueCalibrationName: JSON.stringify(params)
    })
  }

  // function onSubmit() {

  // }

  return (
    <div>
      <div className={styles.reportPicBox}>
        <Image src={user?.tonguePic} alt='舌诊' width={200} height={200}/>
      </div>
      <div className={styles.btnsWrap}>
        <CheckListButton
          options={options}
          defaultValue={
            user?.seniorInquiry?.tyTongueCalibrationName
            && JSON.parse(user?.seniorInquiry?.tyTongueCalibrationName)
          }
          readonly={readonly}
          onChange={onChange}
        />
        {/* <div className={styles.submitBtn}>
          <Button type="primary" onClick={onSubmit}>确定</Button>
        </div> */}
      </div>
    </div>
  )
}

export default TongueCalibration;